class Parenthesis {
public:
    bool chkParenthesis(string s, int n) {
        stack<char> tmp;
        for (auto c : s)
        {
            if (c == '(' || c == '[' || c == '{')
                tmp.push(c);
            else if (!tmp.empty())
            {
                char top = tmp.top();
                if ((top == '(' && c != ')')
                    || (top == '[' && c != ']')
                    || (top == '{' && c != '}'))
                {
                    return false;
                }
                tmp.pop();
            }
            else
                return false;
        }
        if (tmp.empty())
            return true;
        return false;
    }
};